import java.util.Stack;
//用两个栈实现队列：
public class MyQueue {
    Stack<Integer> stack1 = new Stack<>();
    Stack<Integer> stack2 = new Stack<>();

    public void push(int x) {
        stack1.push(x);
    }

    public int pop() {
        int size = stack1.size();
        for (int i = 0; i < size - 1; i++) {
            stack2.push(stack1.pop());
        }int x = stack1.pop();
        for (int i = 0; i < size - 1; i++) {
            stack1.push(stack2.pop());
        }return x;
    }

    public int peek() {
        int size = stack1.size();
        for (int i = 0; i < size ; i++) {
            stack2.push(stack1.pop());
        }int x = stack2.peek();
        for (int i = 0; i < size ; i++) {
            stack1.push(stack2.pop());
        }return x;
    }

    public boolean empty() {
        return stack1.isEmpty();
    }
}
